<?php
class ActivityValentineOrderVo extends SzAbstractMySqlVo
{

    private $userId;
    private $position;
    private $indexId;
    private $costItem;
    private $reward;
    private $loveNum;
    private $coolDown;

    /**
     * Initialize ActivityValentineOrderVo.
     *
     * @param $userId
     * @param $position
     * @param $indexId
     * @param $costItem
     * @param $reward
     * @param $loveNum
     * @param $coolDown
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return ActivityValentineOrderVo
     */
    public function __construct($userId, $position, $indexId, $costItem, $reward, $loveNum, $coolDown, $isInsert = false) {
        $this->userId = $userId;
        $this->position = $position;
        $this->indexId = $indexId;
        $this->costItem = json_decode($costItem, true);
        $this->reward = json_decode($reward, true);
        $this->loveNum = $loveNum;
        $this->coolDown = $coolDown;

        $this->isInsert = $isInsert;
        $this->voClassName = 'ActivityValentineOrderVo';
        $this->ormName = 'ActivityValentineOrder';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'position' => $this->getPosition(),
            'indexId' => $this->getIndexId(),
            'costItem' => ($needEncode) ? $this->getCostItem() : $this->getRawCostItem(),
            'reward' => ($needEncode) ? $this->getReward() : $this->getRawReward(),
            'loveNum' => $this->getLoveNum(),
            'coolDown' => $this->getCoolDown(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'userId' => $this->getUserId(),
            'position' => $this->getPosition(),
            'indexId' => $this->getIndexId(),
            'costItem' => ($needEncode) ? $this->getCostItem() : $this->getRawCostItem(),
            'reward' => ($needEncode) ? $this->getReward() : $this->getRawReward(),
            'loveNum' => $this->getLoveNum(),
            'coolDown' => $this->getCoolDown(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getUserId(),
            $this->getPosition(),
            $this->getIndexId(),
            $this->getCostItem(),
            $this->getReward(),
            $this->getLoveNum(),
            $this->getCoolDown(),
        );
    }

    public function getUserId()
    {
        return $this->userId;
    }

    public function setUserId($val)
    {
        $this->saveColumnStatus(0, $this->userId);
        $this->userId = $val;
    }

    public function getPosition()
    {
        return $this->position;
    }

    public function setPosition($val)
    {
        $this->saveColumnStatus(1, $this->position);
        $this->position = $val;
    }

    public function getIndexId()
    {
        return $this->indexId;
    }

    public function setIndexId($val)
    {
        $this->saveColumnStatus(2, $this->indexId);
        $this->indexId = $val;
    }

    public function getCostItem()
    {
        return json_encode($this->costItem);
    }

    public function getRawCostItem()
    {
        return $this->costItem;
    }

    public function setCostItem($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 12800) {
            SzLogger::get()->error('[ActivityValentineOrderVo] The length of column costItem exceed the limit, length / limit: ' . $encodedLength . ' / 12800');
            throw new SzException(10522, array('ActivityValentineOrderVo', '12800', $encodedLength));
        } else if ($encodedLength > 11520) {
            SzLogger::get()->warn('[ActivityValentineOrderVo] The length of column costItem exceed the warning level, length / limit: ' . $encodedLength . ' / 12800');
        }
        $this->saveColumnStatus(3, $this->costItem);
        $this->costItem = $val;
    }

    public function getReward()
    {
        return json_encode($this->reward);
    }

    public function getRawReward()
    {
        return $this->reward;
    }

    public function setReward($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 12800) {
            SzLogger::get()->error('[ActivityValentineOrderVo] The length of column reward exceed the limit, length / limit: ' . $encodedLength . ' / 12800');
            throw new SzException(10522, array('ActivityValentineOrderVo', '12800', $encodedLength));
        } else if ($encodedLength > 11520) {
            SzLogger::get()->warn('[ActivityValentineOrderVo] The length of column reward exceed the warning level, length / limit: ' . $encodedLength . ' / 12800');
        }
        $this->saveColumnStatus(4, $this->reward);
        $this->reward = $val;
    }

    public function getLoveNum()
    {
        return $this->loveNum;
    }

    public function setLoveNum($val)
    {
        $this->saveColumnStatus(5, $this->loveNum);
        $this->loveNum = $val;
    }

    public function getCoolDown()
    {
        return $this->coolDown;
    }

    public function setCoolDown($val)
    {
        $this->saveColumnStatus(6, $this->coolDown);
        $this->coolDown = $val;
    }

}